<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">

        <a-form-item label="学生学号" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['studentNumber']" placeholder="请输入学生学号"></a-input>
        </a-form-item>
        <a-form-item label="学生姓名" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['studentName']" placeholder="请输入学生姓名"></a-input>
        </a-form-item>
        <a-form-item label="学生性别" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['studentSex']" placeholder="请输入学生性别"></a-input>
        </a-form-item>
        <a-form-item label="学生出生年月" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <j-date placeholder="请选择学生出生年月" v-decorator="['studnetBirthday']" :trigger-change="true" style="width: 100%"/>
        </a-form-item>
        <a-form-item label="学生名族" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['studentNation']" placeholder="请输入学生名族"></a-input>
        </a-form-item>
        <a-form-item label="学生身份证账号" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['studentIdCard']" placeholder="请输入学生身份证账号"></a-input>
        </a-form-item>
        <a-form-item label="学生政治面貌" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['studentZzmm']" placeholder="请输入学生政治面貌"></a-input>
        </a-form-item>
        <a-form-item label="学生家庭人口数" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['studentJreks']" placeholder="请输入学生家庭人口数"></a-input>
        </a-form-item>
        <a-form-item label="学生在校月开销" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['studentZxykx']" placeholder="请输入学生在校月开销"></a-input>
        </a-form-item>
        <a-form-item label="学生是否建档立卡" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['studentSfjdlk']" placeholder="请输入学生是否建档立卡"></a-input>
        </a-form-item>
        <a-form-item label="入学前户口" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['studentRxqhk']" placeholder="请输入入学前户口"></a-input>
        </a-form-item>
        <a-form-item label="是否单亲" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['studentSfdc']" placeholder="请输入是否单亲"></a-input>
        </a-form-item>
        <a-form-item label="是否孤残" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['studentSfgc']" placeholder="请输入是否孤残"></a-input>
        </a-form-item>
        <a-form-item label="是否烈士或优抚对象子女" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['studentSflshyfdxzn']" placeholder="请输入是否烈士或优抚对象子女"></a-input>
        </a-form-item>
        <a-form-item label="家庭人均年收入" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['studentJtrjnsr']" placeholder="请输入家庭人均年收入"></a-input>
        </a-form-item>
        <a-form-item label="系别" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['studentDeparment']" placeholder="请输入系别"></a-input>
        </a-form-item>
        <a-form-item label="专业" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['studentProfessor']" placeholder="请输入专业"></a-input>
        </a-form-item>
        <a-form-item label="邮政编码" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['studentYzemail']" placeholder="请输入邮政编码"></a-input>
        </a-form-item>
        <a-form-item label="在校联系电话" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['studentPhoneschool']" placeholder="请输入在校联系电话"></a-input>
        </a-form-item>
        <a-form-item label="家庭成员情况" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['studentJtcyqk']" placeholder="请输入家庭成员情况"></a-input>
        </a-form-item>
        <a-form-item label="影响家庭经济状况有关信息" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['studentYxjtjjzkygxx']" placeholder="请输入影响家庭经济状况有关信息"></a-input>
        </a-form-item>
        <a-form-item label="学生陈述申请认定理由" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['studentLy']" placeholder="请输入学生陈述申请认定理由"></a-input>
        </a-form-item>
        <a-form-item label="评议小组意见" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['studentPyxzyjstring']" placeholder="请输入评议小组意见"></a-input>
        </a-form-item>

      </a-form>
    </a-spin>
  </j-modal>
</template>

<script>

  import { httpAction } from '@/api/manage'
  import pick from 'lodash.pick'
  import { validateDuplicateValue } from '@/utils/util'
  import JDate from '@/components/jeecg/JDate'


  export default {
    name: "SmartSchoolPovertyModal",
    components: {
      JDate,
    },
    data () {
      return {
        form: this.$form.createForm(this),
        title:"操作",
        width:800,
        visible: false,
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/smartschoolpoverty/smartSchoolPoverty/add",
          edit: "/smartschoolpoverty/smartSchoolPoverty/edit",
        }
      }
    },
    created () {
    },
    methods: {
      add () {
        this.edit({});
      },
      edit (record) {
        this.form.resetFields();
        this.model = Object.assign({}, record);
        this.visible = true;
        this.$nextTick(() => {
          this.form.setFieldsValue(pick(this.model,'studentNumber','studentName','studentSex','studnetBirthday','studentNation','studentIdCard','studentZzmm','studentJreks','studentZxykx','studentSfjdlk','studentRxqhk','studentSfdc','studentSfgc','studentSflshyfdxzn','studentJtrjnsr','studentDeparment','studentProfessor','studentYzemail','studentPhoneschool','studentJtcyqk','studentYxjtjjzkygxx','studentLy','studentPyxzyjstring','studentStanbdy','studentStanbdyStanbdy'))
        })
      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      handleOk () {
        const that = this;
        // 触发表单验证
        this.form.validateFields((err, values) => {
          if (!err) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            let formData = Object.assign(this.model, values);
            console.log("表单提交数据",formData)
            httpAction(httpurl,formData,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
              that.close();
            })
          }

        })
      },
      handleCancel () {
        this.close()
      },
      popupCallback(row){
        this.form.setFieldsValue(pick(row,'studentNumber','studentName','studentSex','studnetBirthday','studentNation','studentIdCard','studentZzmm','studentJreks','studentZxykx','studentSfjdlk','studentRxqhk','studentSfdc','studentSfgc','studentSflshyfdxzn','studentJtrjnsr','studentDeparment','studentProfessor','studentYzemail','studentPhoneschool','studentJtcyqk','studentYxjtjjzkygxx','studentLy','studentPyxzyjstring','studentStanbdy','studentStanbdyStanbdy'))
      },


    }
  }
</script>